package com.czx.tablayoutnavigatioinview;

import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    private TabLayout mTabLayout;
    private NoScrollViewPager mViewPager;

    private TabLayout.Tab one;
    private TabLayout.Tab two;
    private TabLayout.Tab three;
    private TabLayout.Tab four;
    private TabLayout.Tab five;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mTabLayout = (TabLayout) findViewById(R.id.tabLayout_main);
        mViewPager = (NoScrollViewPager) findViewById(R.id.viewPager_main);

        mViewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager()));
        mTabLayout.setupWithViewPager(mViewPager);

        one = mTabLayout.getTabAt(0);
        two = mTabLayout.getTabAt(1);
        three = mTabLayout.getTabAt(2);
        four = mTabLayout.getTabAt(3);
        five = mTabLayout.getTabAt(4);

        one.setIcon(ContextCompat.getDrawable(this,R.drawable.ic_looks_one_black_24dp));
        two.setIcon(ContextCompat.getDrawable(this,R.drawable.ic_looks_two_black_24dp));
        three.setIcon(ContextCompat.getDrawable(this,R.drawable.ic_looks_3_black_24dp));
        four.setIcon(ContextCompat.getDrawable(this,R.drawable.ic_looks_4_black_24dp));
        five.setIcon(ContextCompat.getDrawable(this,R.drawable.ic_looks_5_black_24dp));

    }
}
